import {Component, animate, state, style, transition, trigger} from '@angular/core';
@Component({
    selector: 'my-tirgger',
    styles: [`
    .toggle-container {
      background-color:white;
      border:10px solid black;
      width:200px;
      text-align:center;
      line-height:100px;
      font-size:50px;
      box-sizing:border-box;
      overflow:hidden;
    }
  `],
    animations: [trigger(
        'openClose',
        [
            state('collapsed, void', style({ width: '0px', color: 'maroon', borderColor: 'maroon' })),
            state('expanded', style({ width: '*', borderColor: 'green', color: 'green' })),
            transition(
                'collapsed <=> expanded', [animate(500, style({ width: '250px' })), animate(500)])
        ])],
    template: `
    <button (click)="expand()">Open</button>
    <button (click)="collapse()">Closed</button>
    <hr />
    <div class="toggle-container" [@openClose]="stateExpression">
      Look at this box
    </div>
  `
})
export class TriggerDemo {
    stateExpression: string;
    constructor() { this.collapse(); }
    expand() { this.stateExpression = 'expanded'; }
    collapse() { this.stateExpression = 'collapsed'; }
}